<?php
use LaravelBook\Ardent\Ardent;

class Address extends Ardent {
	protected $table;
	public $timestamps = false;
	
	public static $rules = array(
			'country_id' => 'required|numeric',
			'zip' => 'required|max:10',
			'city' => 'required|max:50',
			'street' => 'required|max:50',
			'detail' => 'max:500'
	);
	
	public static $customMessages = array(
			'country_id.required' => 'Land muss gesetzt sein!',
			'country_id.numeric' => 'Land muss ein numerischer Wert sein!',
			'zip.required' => 'PLZ muss gesetzt sein!',
			'zip.max' => 'PLZ darf max. 10 zeichen beinhalten!',
			'city.required' => 'Stadt muss gesetzt sein!',
			'city.max' => 'Stadt darf max. 50 Zeichen beinhalten!',
			'street.required' => 'Straße muss gesetzt sein!',
			'street.max' => 'Straße darf max. 50 Zeichen beinhalten!',
			'detail.max' => 'Detail darf max. 500 Zeichen beinhalten!'
	);
	
	
	/********************************************************************************
	 ******************************** PUBLIC FUNCTIONS ******************************
	 ********************************************************************************/
	
	
	/**
	 * ses the table for the model
	 */
	public function __construct() {
		$this->table = Helper::getDB ('core') . 'address';
		parent::__construct();
	}
	
	
	/**********************************************************************
	 ************************** HAS MANY RELATIONS ************************
	 **********************************************************************/
	
	
	/**********************************************************************
	 ************************* BELONGS TO RELATIONS ***********************
	 **********************************************************************/
	
	/**
	 * returns the country
	 * @return		mixed
	 */
	public function country(){
		return $this->belongsTo('Country', 'country_id');
	}
}